package first.group.ssh.channel;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Map;

public final class ChannelRequestParser {
    private ChannelRequestParser() {
    }
    
    private static final Map<String, ChannelRequest.Parser<?>> REQUESTS = Map.ofEntries();
    
    public static boolean isSupported(String name) {
        return REQUESTS.containsKey(name);
    }
    
    public static ChannelRequest parse(String name, ByteBuffer buffer) throws IOException {
        var parser = REQUESTS.get(name);
        if (parser == null) {
            return null;
        }
        return parser.parse(buffer);
    }
}
